<template>
	<view>
		<view class="total-score">
			<span>当前积分：<label>{{score}}</label></span>
			<button type="primary" size="mini" style="position: absolute;right: 20px;top:30px" @click="toApplyHis">申请历史</button>
		</view>
		<uni-list>
			<uni-list-item v-for="l of logs" :key="l.id" :title="l.action|scoreType" :note="l.create_time" :rightText="l.score" />
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				score: 0,
				logs: []
			}
		},
		onLoad(e) {
			this.loadScore()
			this.loadLog()
		},
		methods: {
			loadScore() {
				this.$http.get('/web/ai/score/total', {}, (resp) => {
					console.log("score:", resp)
					this.score = resp
				})
			},
			loadLog() {
				this.$http.get('/web/ai/score/log', {
					page: 1,
					size: 50
				}, (resp) => {
					this.logs = resp.items
				})
			},
			toApplyHis(){
				uni.navigateTo({
					url:'/uni_modules/zgj-pages/pages/score/scoreAplyHis'
				})
			}
		}
	}
</script>

<style>
.total-score{
	position: relative;
	padding: 20px;
}
.total-score span{
	font-size: 17px;
}
.total-score label{
	font-size: 32px;
}
</style>